<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="uuid">
              <a-input v-model="model.uuid" placeholder="请输入编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车道类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="laneType">
              <j-dict-select-tag type="list" v-model="model.laneType" dictCode="card_lane_type" placeholder="请选择车道类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="推送类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pushType">
              <j-dict-select-tag type="list" v-model="model.pushType" dictCode="car_push_type" placeholder="请选择推送类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车辆业务 ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="carAccessCurId">
              <a-input v-model="model.carAccessCurId" placeholder="请输入车辆业务 ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车 牌 号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="carNum">
              <a-input v-model="model.carNum" placeholder="请输入车 牌 号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="推 送 时 间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actTime">
              <a-input v-model="model.actTime" placeholder="请输入推 送 时 间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预进场/进场时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="arriveTime">
              <a-input v-model="model.arriveTime" placeholder="请输入预进场/进场时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="离 场 时 间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="leaveTime">
              <a-input v-model="model.leaveTime" placeholder="请输入离 场 时 间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="停车时长" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="parkingTimeLength">
              <a-input v-model="model.parkingTimeLength" placeholder="请输入停车时长"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车辆类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="vehicleClass">
              <j-dict-select-tag type="list" v-model="model.vehicleClass" dictCode="car_vehicle_class" placeholder="请选择车辆类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="道闸通道编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="vttDevChnid">
              <a-input v-model="model.vttDevChnid" placeholder="请输入道闸通道编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="道闸名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sluiceDevChnName">
              <a-input v-model="model.sluiceDevChnName" placeholder="请输入道闸名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车道号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="laneNo">
              <a-input v-model="model.laneNo" placeholder="请输入车道号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="停车场 ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="parkingLotCode">
              <a-input v-model="model.parkingLotCode" placeholder="请输入停车场 ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="余位数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="totRemianNum">
              <a-input v-model="model.totRemianNum" placeholder="请输入余位数"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JdOutCardForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/jd/jdOutCard/add",
          edit: "/jd/jdOutCard/edit",
          queryById: "/jd/jdOutCard/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>